package org.leviatan.definator.client.ejb;

import java.rmi.RemoteException;
import java.util.Collection;
import java.util.HashMap;

import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

import org.leviatan.definator.core.admin.DefinatorAdminService;
import org.leviatan.definator.core.admin.DefinatorAdminServiceImpl;
import org.leviatan.definator.core.model.Field;
import org.leviatan.definator.core.model.Record;
import org.leviatan.definator.core.model.Table;

/**
 * @ejb.bean name="DefinatorService"
 *           display-name="Name for DefinatorService"
 *           description="Description for DefinatorService"
 *           jndi-name="ejb/DefinatorService"
 *           type="Stateless"
 *           view-type="both"
 */
public class DefinatorServiceEJB implements SessionBean, DefinatorAdminService {

	private static final long serialVersionUID = -2050741047392578699L;

	
	
	public DefinatorServiceEJB() {
	}

	/**
	 * Default create method
	 * 
	 * @throws CreateException
	 * @ejb.create-method
	 */
	public void ejbCreate() throws CreateException {
		// TODO Auto-generated method stub
	}

	public void ejbActivate() throws EJBException, RemoteException {
		// TODO Auto-generated method stub
	}

	public void ejbPassivate() throws EJBException, RemoteException {
		// TODO Auto-generated method stub
	}

	public void ejbRemove() throws EJBException, RemoteException {
		// TODO Auto-generated method stub
	}

	public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException {
		// TODO Auto-generated method stub	
	}

	
	/* Interface methods */
	///////////////////////////////////////////////////////////////////////////
	/**
	 * @ejb.interface-method
	 */
	public HashMap getFieldDefinitions() {
		return (HashMap) DefinatorAdminServiceImpl.getService().getFieldDefinitions();
	}

	/**
	 * @ejb.interface-method
	 */
	public HashMap getRecordDefinitions() {
		return (HashMap) DefinatorAdminServiceImpl.getService().getRecordDefinitions();
	}

	/**
	 * @ejb.interface-method
	 */
	public HashMap getTableDefinitions() {
		return (HashMap) DefinatorAdminServiceImpl.getService().getTableDefinitions();
	}

	/**
	 * @ejb.interface-method
	 */
	public Field getFieldModel(String aId) {
		return DefinatorAdminServiceImpl.getService().getFieldModel(aId);
	}

	/**
	 * @ejb.interface-method
	 */
	public Record getRecordModel(String aId) {
		return DefinatorAdminServiceImpl.getService().getRecordModel(aId);
	}

	/**
	 * @ejb.interface-method
	 */
	public Collection getRecordsFieldIds(String recId) {
		return DefinatorAdminServiceImpl.getService().getRecordsFieldIds(recId);
	}

	/**
	 * @ejb.interface-method
	 */
	public Table getTableModel(String aId) {
		return DefinatorAdminServiceImpl.getService().getTableModel(aId);
	}

	/**
	 * @ejb.interface-method
	 */
	public Collection getTablesRecordIds(String tblId) {
		return DefinatorAdminServiceImpl.getService().getTablesRecordIds(tblId);
	}

	/**
	 * @ejb.interface-method
	 */
	public String getFieldsRecordId(String fldId) {
		return DefinatorAdminServiceImpl.getService().getFieldsRecordId(fldId);
	}

	/**
	 * @ejb.interface-method
	 */
	public String getRecordsTableId(String recId) {
		return DefinatorAdminServiceImpl.getService().getRecordsTableId(recId);
	}

	/**
	 * @ejb.interface-method
	 */
	public Field addFieldModel(Field fld) {
		return DefinatorAdminServiceImpl.getService().addFieldModel(fld);
	}

	/**
	 * @ejb.interface-method
	 */
	public Record addRecordModel(Record rec) {
		return DefinatorAdminServiceImpl.getService().addRecordModel(rec);
	}

	/**
	 * @ejb.interface-method
	 */
	public Table addTableModel(Table tbl) {
		return DefinatorAdminServiceImpl.getService().addTableModel(tbl);
	}

	/**
	 * @ejb.interface-method
	 */
	public void loadModels() {
		DefinatorAdminServiceImpl.getService().loadModels();
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean removeFieldModel(String fldId) {
		return DefinatorAdminServiceImpl.getService().removeFieldModel(fldId);
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean removeRecordModel(String recId) {
		return DefinatorAdminServiceImpl.getService().removeRecordModel(recId);
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean removeTableModel(String tblId) {
		return DefinatorAdminServiceImpl.getService().removeTableModel(tblId);
	}

	/**
	 * @ejb.interface-method
	 */
	public void saveModels() {
		DefinatorAdminServiceImpl.getService().saveModels();
	}

	/**
	 * @ejb.interface-method
	 */
	public void loadRegister() {
		DefinatorAdminServiceImpl.getService().loadRegister();
	}

	/**
	 * @ejb.interface-method
	 */
	public void loadConfiguration(String filePath) {
		DefinatorAdminServiceImpl.getService().loadConfiguration(filePath);
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean updateFieldModel(String fldId, Field fldModel) {
		return DefinatorAdminServiceImpl.getService().updateFieldModel(fldId, fldModel);
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean updateRecordModel(String recId, Record recModel) {
		return DefinatorAdminServiceImpl.getService().updateRecordModel(recId, recModel);
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean updateTableModel(String tblId, Table tblModel) {
		return DefinatorAdminServiceImpl.getService().updateTableModel(tblId, tblModel);
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean updateFieldLength(String fldId, int newLength) {
		return DefinatorAdminServiceImpl.getService().updateFieldLength(fldId, newLength);
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean updateFieldModel(String fldId, String newName, int newLength, String newType, String newRef) {
		return DefinatorAdminServiceImpl.getService().updateFieldModel(fldId, newName, newLength, newType, newRef);
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean updateFieldName(String fldId, String newName) {
		return DefinatorAdminServiceImpl.getService().updateFieldName(fldId, newName);
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean updateFieldRecordRef(String fldId, String newRef) {
		return DefinatorAdminServiceImpl.getService().updateFieldRecordRef(fldId, newRef);
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean updateFieldType(String fldId, String newType) {
		return DefinatorAdminServiceImpl.getService().updateFieldType(fldId, newType);
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean updateRecordName(String recId, String newName) {
		return DefinatorAdminServiceImpl.getService().updateRecordName(recId, newName);
	}

	/**
	 * @ejb.interface-method
	 */
	public boolean updateTableName(String tblId, String newName) {
		return DefinatorAdminServiceImpl.getService().updateTableName(tblId, newName);
	}

	/**
	 * @ejb.interface-method
	 */
	public String createNewFieldModel() {
		return DefinatorAdminServiceImpl.getService().createNewFieldModel();
	}

	/**
	 * @ejb.interface-method
	 */
	public String createNewFieldModel(String name, int length, String type, String recRef) {
		return DefinatorAdminServiceImpl.getService().createNewFieldModel(
				name, length, type, recRef);
	}

	/**
	 * @ejb.interface-method
	 */
	public String createNewRecordModel() {
		return DefinatorAdminServiceImpl.getService().createNewRecordModel();
	}

	/**
	 * @ejb.interface-method
	 */
	public String createNewRecordModel(String name, String tblRef) {
		return DefinatorAdminServiceImpl.getService().createNewRecordModel(name, tblRef);
	}
	
	/**
	 * @ejb.interface-method
	 */
	public String createNewTableModel() {
		return DefinatorAdminServiceImpl.getService().createNewTableModel();
	}

	/**
	 * @ejb.interface-method
	 */
	public String createNewTableModel(String name) {
		return DefinatorAdminServiceImpl.getService().createNewTableModel(name);
	}
 

}
